import { notify } from '@/widgets'
import { selectEntityIdByType, showEntityTablePartial } from '../table'
import { getWaypointATSRouteSet } from './atsroute-index'
import type { ATSRoute } from './types'

export function showWaypointATSRouteTable(wpt: string) {
  const as = getWaypointATSRouteSet(wpt)
  if (!as || as.size === 0) {
    notify.info({ content: `航路点${wpt}没有对应航路!` })
    return
  }
  showEntityTablePartial<ATSRoute>({
    key: `@@atsr-by-wpt-${wpt}`,
    type: 'ATSRoute',
    data: () => [...as],
    name: `航路点对应航路 | ${wpt} (${as.size})`
  })
}

export function selectAndShowWaypointATSRouteTable() {
  selectEntityIdByType('Waypoint', showWaypointATSRouteTable)
}
